package com.example.gty.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket getDocket(){

        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.gty.controller"))//访问该包下所有类
                .paths(PathSelectors.any()) //访问所有接口
                .build();
        return docket;
    }

    private ApiInfo getApiInfo(){
        Contact contact = new Contact("李某", "www.li.com", "1821920744@qq.com");
        ApiInfo apiInfo = new ApiInfo(
                "《学生成绩管理系统后端接口说明》",
                "此文档详细说明后端接口规范",
                "1.0.0","无",contact,"无","无",new ArrayList<>());
        return apiInfo;

    }
}
